package main

import (
	"fmt"
	"sync"
)

func main() {
	var wg sync.WaitGroup
	wg.Add(2)
	var ch = make(chan int, 5)
	go send(ch, &wg)
	go recv(ch, &wg)

	wg.Wait()

}

func send(ch chan<- int, wg *sync.WaitGroup) {
	for i := range 100 {
		ch <- i
	}
	close(ch)
	wg.Done()
}

func recv(ch <-chan int, wg *sync.WaitGroup) {
	for i := range ch {
		fmt.Println(i)
	}
	wg.Done()
}
